import com.paas.common.jdbc.JdbcSql;
import com.paas.common.jdbc.model.DbResult;
import com.paas.plus.tool.form.util.TransformDateUtil;
import org.junit.Test;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

public class ExecuteJdbcSql {

    @Test
    public void testJdbcSql(){
        String userName = "ccspms";
        String password = "ccslwc!123$";
        String driver = "com.mysql.jdbc.Driver";
        String sql = "update dws_cus_customer_di set revocation_date = ? where id =?";
        String jdbcUrl = "jdbc:mysql://11.224.0.96:3306/demo-mdm?useUnicode=true&useOldAliasMetadataBehavior=true";
        JdbcSql jdbcSql = new JdbcSql(driver, jdbcUrl, userName, password);
        //List<List<Object>> listList = new ArrayList<>();
        List<Object> objectArrayList = new ArrayList<>();
        String date = "2023-04-29 12:22:14.0";
        Timestamp timestamp = Timestamp.valueOf(date);
        objectArrayList.add(timestamp);

        objectArrayList.add(1);
        //listList.add(objectArrayList);
        jdbcSql.executeUpdate(sql, objectArrayList.toArray());
    }

    @Test
    public void testPgJdbcSql(){
        String userName = "ccsadmin";
        String password = "rpsmptimc123$";
        String driver = "org.postgresql.Driver";
        String sql = "update customer_info set create_date = ? where id =?";
        String jdbcUrl = "jdbc:postgresql://11.224.0.189:5432/ccscw";
        JdbcSql jdbcSql = new JdbcSql(driver, jdbcUrl, userName, password);
        List<Object> objectArrayList = new ArrayList<>();
        String date = "2023-03-13 20:22:59.605";
        Object value = TransformDateUtil.formatDateValue(date);
        //Timestamp timestamp = Timestamp.valueOf(date);
        objectArrayList.add(value);
        objectArrayList.add("7496e663e2a644a9bc18e7d7aa1530f2");
        jdbcSql.executeUpdate(sql, objectArrayList.toArray());
    }
}
